import React, { Component } from 'react';

class Son extends Component {
    state = {
        username: "房祖名",
        age: 20
    }
    render() {
        return (
            <div>
                <p>我是子组件</p>
                <button onClick={this.toFatherFn}>子传父</button>
            </div>
        );
    };
    toFatherFn = () => {
        this.props.fun(this.state.username)
    }

    getstatetofatherFn() {
        return this.state.age
    }

}

export default Son;
